<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>欢迎页面-X-admin2.0</title>
    <meta name="renderer" content="webkit">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"
    />
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="./css/font.css">
    <link rel="stylesheet" href="./css/xadmin.css">
    
    <script type="text/javascript" src="./js/jquery.min.js"></script>
    <script src="./js/lib.js"></script>
    <script type="text/javascript" src="./lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="./js/xadmin.js"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
      <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
      <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
    <style>
        .bg-disable{
            background:#ccc;
        }
    </style>
</head>

<body>
    <div class="x-nav">
        <span class="layui-breadcrumb">
            <a href="">首页</a>
            <a href="">演示</a>
            <a>
                <cite>导航元素</cite>
            </a>
        </span>
        <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);"
            title="刷新">
            <i class="layui-icon" style="line-height:30px">ဂ</i>
        </a>
    </div>
    <div class="x-body">
        <div class="x-body">
            <form class="layui-form">
                <div class="layui-form-item">
                    <label for="" class="layui-form-label">
                        <span class="x-red">*</span>活动名-简体
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="ptlNameCn" required lay-verify="required" autocomplete="off" class="layui-input ">
                    </div>
                    <label for="" class="layui-form-label">
                        <span class="x-red">*</span>活动名-繁体
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="ptlNameTw" required lay-verify="required" autocomplete="off" class="layui-input">
                    </div>
                    <label for="" class="layui-form-label">
                        <span class="x-red">*</span>活动名-英文
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="ptlNameEn" required lay-verify="required" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="" class="layui-form-label">
                        <span class="x-red">*</span>描述-简体
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="introCn" required lay-verify="required" autocomplete="off" class="layui-input">
                    </div>
                    <label for="" class="layui-form-label">
                        <span class="x-red">*</span>描述-繁体
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="introTw" required lay-verify="required" autocomplete="off" class="layui-input">
                    </div>
                    <label for="" class="layui-form-label">
                        <span class="x-red">*</span>描述-英文
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="introEn" required lay-verify="required" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="" class="layui-form-label">
                        <span class="x-red">*</span>活动类型
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="ptlType" required lay-verify="required" autocomplete="off" class="layui-input bg-disable" disabled>
                    </div>
                    <label for="" class="layui-form-label">
                        <span class="x-red">*</span>创建管理员
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="admin" required lay-verify="required" autocomplete="off" class="layui-input bg-disable" disabled>
                    </div>
                    <label for="" class="layui-form-label">
                        <span class="x-red">*</span>创建时间
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="createTime" required lay-verify="required" autocomplete="off" class="layui-input bg-disable" disabled>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="" class="layui-form-label">
                        <span class="x-red">*</span>数值
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="num" required lay-verify="required" autocomplete="off" class="layui-input">
                    </div>
                    <label for="" class="layui-form-label">
                        <span class="x-red">*</span>条件
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="limit" required lay-verify="required" autocomplete="off" class="layui-input bg-disable" disabled>
                    </div>
                    <label for="" class="layui-form-label">
                        <span class="x-red">*</span>状态('0'表示停止，'1'表示活动正在进行)
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="status" required lay-verify="required" autocomplete="off" class="layui-input">
                    </div>
                </div>
                 <button class="layui-btn" lay-filter="modify" lay-submit>
                    确认修改
                 </button>
            </form>
        </div>
    </div>

    <script>
        $(function (event) {
            layui.use(['layer', 'form'], function () {
                var layer = layui.layer;
                var form = layui.form;
                var aId = Cookies.get('kplus-helmetAdminId')
                var aToken = Cookies.get('kplus-helmetAdminToken')
                var loadindex1 = layer.load(1, {
                    shade: [0.5, '#000']
                });
                function getPtlInfo() {
                    ajax({
                        'url': bAsEuRl + uRlS.ptl,
                        'type': 'GET',
                        'data': {
                            'aId': aId,
                            'aToken': aToken,
                            'wId': getParam('w_ptl')
                        },
                        success: function (data) {
                            if (data.msg.code == 200) {
                                //console.log(data)
                                var ptlData = data.data;
                                var createTime = formatTime(ptlData.formatTime)
                                $('#ptlNameCn').val(ptlData.ptlName.cn)    
                                $('#ptlNameTw').val(ptlData.ptlName.tw)  
                                $('#ptlNameEn').val(ptlData.ptlName.en)  
                                $('#createTime').val(createTime)    
                                $('#introCn').val(ptlData.ptlIntro.cn)  
                                $('#introTw').val(ptlData.ptlIntro.tw)  
                                $('#introEn').val(ptlData.ptlIntro.en)  
                                $('#num').val(ptlData.discount)  
                                $('#ptlType').val(ptlData.ptlType) 
                                $('#admin').val(ptlData.createAdmin) 
                                $('#status').val(ptlData.ptlStatus)  
                                $('#limit').val(ptlData.ptlType)
                                layer.close(loadindex1);  //关闭loaidn 
                            } else {
                                layer.close(loadindex1);  //关闭loaidn
                                layer.msg(data.msg.msg, {
                                    time: 2000
                                })
                            }
                        },
                        error: function (data) {
                            alert('发生严重错误！')
                        }
                    })
                }
                getPtlInfo();   
                
                function modifyPtl() {
                    var data = {
                        'aId': aId,
                        'aToken': aToken,
                        'wId': getParam('w_ptl'),
                        'name': 'cn:' + $('#ptlNameCn').val() + '|en:' + $('#ptlNameEn').val() + '|tw:' + $('#ptlNameTw').val(),
                        'intro': 'cn:' + $('#introCn').val() + '|en:' + $('#introEn').val() + '|tw:' + $('#introTw').val(),
                        'num': $('#num').val(),
                        'status':$('#status').val()
                    }
                    var loadindex2 = layer.load(1, {
                        shade: [0.5, '#000']
                    }); 
                    $.ajax({
                        'url': bAsEuRl + uRlS.ptl,
                        'type': 'POST',
                        'data': data,
                        success: function (data) { 
                            if(data.msg.code == 200){
                                console.log(data)

                                layer.close(loadindex2);
                            }else{
                                layer.msg(data.msg.msg, {time: 2000})
                                layer.close(loadindex2);
                            }
                         },
                         error: function (data) { 
                             layer.close(loadindex2);
                             layer.msg('发生严重错误！联系系统维护人员')
                          }
                    })
                }
                form.on('submit(modify)', function (data) { 
                    modifyPtl();
                    return false;
                })

            })
        })
    </script>



</body>

</html>